package com.yanq.liancar.activity;
/*
 *  @创建者     Administrator
 *  @创建时间   2018/12/2  11:43
 *  @描述       ${TODO}
 */


import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v7.widget.Toolbar;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.gyf.barlibrary.ImmersionBar;
import com.yanq.liancar.R;
import com.yanq.liancar.activity.base.BaseToolbarActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ContactUsActivity extends BaseToolbarActivity {
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_left)
    TextView tvLeft;
    @BindView(R.id.tv_right)
    TextView tvRight;
    @BindView(R.id.iv_right2)
    ImageView ivRight2;
    @BindView(R.id.iv_right)
    ImageView ivRight;
    @BindView(R.id.common_toolbar)
    Toolbar commonToolbar;
    @BindView(R.id.action_bar)
    AppBarLayout actionBar;
    @BindView(R.id.tv_Hotline)
    TextView tvHotline;
    @BindView(R.id.tv_Business_unit)
    TextView tvBusinessUnit;
    @BindView(R.id.tv_website)
    TextView tvWebsite;
    @BindView(R.id.tv_mailbox)
    TextView tvMailbox;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_contactus);
        ButterKnife.bind(this);
        mTvTitle.setText("联系我们");
        ImmersionBar.with(this).statusBarColor(R.color.white).statusBarDarkFont(true).init();

        SpannableString spannableString1 = new SpannableString("全国客服热线：4008-055-011");
        ForegroundColorSpan colorSpan1 = new ForegroundColorSpan(getResources().getColor(R.color.main_color));
        spannableString1.setSpan(colorSpan1, 7, spannableString1.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        ForegroundColorSpan colorSpan4 = new ForegroundColorSpan(getResources().getColor(R.color.background_content));
        spannableString1.setSpan(colorSpan4, 0, 7, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tvHotline.setText(spannableString1);

        SpannableString spannableString2 = new SpannableString("车联网事业部：18758884529");
        spannableString2.setSpan(colorSpan1, 7, spannableString2.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        spannableString2.setSpan(colorSpan4, 0, 7, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tvBusinessUnit.setText(spannableString2);

        SpannableString spannableString3 = new SpannableString("官网：www.zhimaikeji.com");
        spannableString3.setSpan(colorSpan1, 3, spannableString3.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        spannableString3.setSpan(colorSpan4, 0, 3, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tvWebsite.setText(spannableString3);

        SpannableString spannableString4 = new SpannableString("E-mail：postmaster@zhimaixinxi.onaliyun.com");
        spannableString4.setSpan(colorSpan1, 7, spannableString4.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        spannableString4.setSpan(colorSpan4, 0, 7, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tvMailbox.setText(spannableString4);


    }

    @OnClick({R.id.tv_Hotline, R.id.tv_Business_unit, R.id.tv_website, R.id.tv_mailbox})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_Hotline:
                Intent intent1 = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "4008055011"));
                intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent1);
                break;
            case R.id.tv_Business_unit:
                Intent intent2 = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "18758884529"));
                intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent2);
                break;
            case R.id.tv_website:
                Uri uri = Uri.parse("https://www.zhimaikeji.com");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);
                break;
            case R.id.tv_mailbox:
                Intent i = new Intent(Intent.ACTION_SEND);
                // i.setType("text/plain"); //模拟器请使用这行
                i.setType("message/rfc822"); // 真机上使用这行
                i.putExtra(Intent.EXTRA_EMAIL,
                        new String[] { "postmaster@zhimaixinxi.onaliyun.com" });
                i.putExtra(Intent.EXTRA_SUBJECT, "您的建议");
                i.putExtra(Intent.EXTRA_TEXT, "我们很希望能得到您的建议！！！");
                startActivity(Intent.createChooser(i, "Select email application."));
                break;
        }
    }
}
